﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class SidebarAnimation : MonoBehaviour {
    public RectTransform[] button;
    public bool isanimat=false;
    public RectTransform form;
	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {
        if (isanimat)
        {
            //foreach (var item in button)
            //{
            //    item.DOLocalMove(new Vector3(100, item.localPosition.y, item.localPosition.z), 0.4f);
            //}
        }
	}

    public void Enter()
    {
        isanimat = true;
        foreach (var item in button)
        {
            item.DOAnchorPos(new Vector2(0, item.localPosition.y), 0.4f);
        }
    }
    public void Exit()
    {
        foreach (var item in button)
        {
            if (form != item)
                item.DOAnchorPos(new Vector2(80, item.localPosition.y), 0.4f);
            else
                item.DOAnchorPos(new Vector2(0, item.localPosition.y), 0.4f);
        }
    }
    public void Animatoin(RectTransform trans)
    {
        isanimat = false;
        foreach (var item in button)
        {
            if (trans != item)
                item.DOAnchorPos(new Vector2(80, item.localPosition.y), 0.4f);
            else
                item.DOAnchorPos(new Vector2(0, item.localPosition.y), 0.4f);
        }
        form = trans;
    }

}
